//
//  DMPurchaseInfo.m
//  DualMediationSDK
//
//  购买信息模型类实现
//

#import "DMPurchaseInfo.h"

@implementation DMPurchaseInfo

- (instancetype)init {
    self = [super init];
    if (self) {
        _productType = DMProductTypeConsumable;
        _isRestored = NO;
    }
    return self;
}

- (NSString *)description {
    return [NSString stringWithFormat:@"<DMPurchaseInfo: %p> productId=%@, purchaseId=%@, productType=%ld, isRestored=%@",
            self, self.productId, self.purchaseId, (long)self.productType, self.isRestored ? @"YES" : @"NO"];
}

- (BOOL)isEqual:(id)object {
    if (self == object) {
        return YES;
    }
    
    if (![object isKindOfClass:[DMPurchaseInfo class]]) {
        return NO;
    }
    
    DMPurchaseInfo *other = (DMPurchaseInfo *)object;
    return [self.productId isEqualToString:other.productId] &&
           [self.purchaseId isEqualToString:other.purchaseId];
}

- (NSUInteger)hash {
    return [self.productId hash] ^ [self.purchaseId hash];
}

@end